#1.验证ipvv4地址合法性
#1~255.1~255.1~255 1.~255
import re

ip = input("请输入ip号")

ret = re.findall(r"^(([1-9]\d?|1\d{2}|2[2-4]\d|25[0-5]).){3}([1-9]\d?|1\d{2}|2[2-4]\d|25[0-5])$",ip)
if ret:
    print(ip,"合法")
else:
    print(ip,"不合法")